<html lang="en-US">

<head>
    
<title>搭建多服务器管理工具Portainer - 花落雨忧</title>

<meta property="og:title" content="搭建多服务器管理工具Portainer - 花落雨忧">



    



    
    <meta property="description" content="背景：我们有很多mini服务器【工业服务器】里面部署了很多容器，想找一款可以集中管理这些容器的工具，于是找到了Portainer
1.安装Partainer
[&amp;hellip;] docker run -d -p 9000:9000 &amp;ndash;name portainer &amp;ndash;restart always -v &amp;hellip;">
    <meta property="og:description" content="背景：我们有很多mini服务器【工业服务器】里面部署了很多容器，想找一款可以集中管理这些容器的工具，于是找到了Portainer
1.安装Partainer
[&amp;hellip;] docker run -d -p 9000:9000 &amp;ndash;name portainer &amp;ndash;restart always -v &amp;hellip;">
    






<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1">

<link rel="shortcut icon" href="https://www.lican.asia/logo/logo.png" type="image/x-icon" />



<link rel="stylesheet" href="/css/style.min.css" />

<link rel="stylesheet" href="/css/reset.min.css" />




<script src="https://www.lican.asia/js/highlight.min.js"></script>

<script>
hljs.configure({ ignoreUnescapedHTML: true })
hljs.highlightAll();
</script>


<script src="https://www.lican.asia/js/jquery.min.js"></script>




<link href="https://www.lican.asia/css/hugo-code.min.css" rel="stylesheet" />



    <style>
        .post-content img {
            max-width: 400px;
        }
    </style>
</head>

<body id="period" class="home blog">
    <a class="skip-content" href="#main">Press "Enter" to skip to content</a>
    <div id="overflow-container" class="overflow-container">
        <header class="site-header" id="site-header" role="banner">
    <div class="max-width">
        <div id="title-container" class="title-container">
            <div id="site-title" class="site-title"><a href="/">花落雨忧</a></div>
            <p class="tagline">思所及 力所行 方为真.</p>
        </div>
        
        <div id="menu-primary-container" class="menu-primary-container">
            <div class="icon-container">
            </div>
            <div id="menu-primary" class="menu-container menu-primary" role="navigation">
                <nav class="menu">
                    <ul id="menu-primary-items" class="menu-primary-items">
                        
                        
                        <li id="menu-item-0"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/posts" aria-current="page" tabindex="0">首页</a></li>
                        
                        <li id="menu-item-1"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/tech/" aria-current="page" tabindex="1">技术文档</a></li>
                        
                        <li id="menu-item-2"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/article/" aria-current="page" tabindex="2">文章</a></li>
                        
                        <li id="menu-item-3"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/project/" aria-current="page" tabindex="3">项目</a></li>
                        
                        <li id="menu-item-4"
                            class="menu-item menu-item-type-custom menu-item-object-custom ">
                            <a href="/about/" aria-current="page" tabindex="4">关于</a></li>
                        
                    </ul>
                </nav>
            </div>
        </div>
    </div>
</header>

        <div id="primary-container" class="primary-container">
            <div class="max-width">
                <section id="main" class="main" role="main">
                    <div id="loop-container" class="loop-container">
                        <div
                            class="post type-post status-publish format-standard hentry entry">
                            <article>
                                <div class="post-container">
                                    <div class="post-header">
                                        <h2 class="post-title">
                                            <a href="/tech/%E6%90%AD%E5%BB%BA%E5%A4%9A%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%AE%A1%E7%90%86%E5%B7%A5%E5%85%B7portainer/">搭建多服务器管理工具Portainer</a>
                                        </h2>
                                        
                                    </div>
                                    <div class="post-content">
                                        <h3 id="搭建多服务器管理工具portainer">搭建多服务器管理工具Portainer</h3>
<p>背景：我们有很多mini服务器【工业服务器】里面部署了很多容器，想找一款可以集中管理这些容器的工具，于是找到了Portainer</p>
<p>1.安装Partainer</p>
<blockquote>
<p>docker run -d -p 9000:9000 &ndash;name portainer     &ndash;restart always     -v /var/run/docker.sock:/var/run/docker.sock     portainer/portainer-ce</p>
</blockquote>
<p>2.启动之后，执行docker ps | grep portainer, 查看运行状态<img src="https://www.lican.asia/images/portainer/1741741989295.png" alt="1741741989295"></p>
<p>3.浏览器中访问ip:9000端口，即可打开portainer界面</p>
<p><img src="https://www.lican.asia/images/portainer/1741742118236.png" alt="1741742118236"></p>
<p>4.点击侧边栏的SETTINGS能看到本地的docker环境</p>
<p><img src="https://www.lican.asia/images/portainer/1741742207626.png" alt="1741742207626"></p>
<p>5.可以查看并操作对应的容器</p>
<p><img src="https://www.lican.asia/images/portainer/1741742244033.png" alt="1741742244033"></p>
<p><img src="https://www.lican.asia/images/portainer/1741742259964.png" alt="1741742259964"></p>
<p>6.添加/管理其它服务器的docker容器</p>
<ul>
<li>
<p>点击侧边栏的Environments-&gt;Add environment</p>
<p><img src="https://www.lican.asia/images/portainer/1741742349874.png" alt="1741742349874"></p>
</li>
<li>
<p>选择docker tab栏，添加配置</p>
<p><img src="https://www.lican.asia/images/portainer/1741742783532.png" alt="1741742783532"></p>
</li>
</ul>
<p>添加时，可能提示 Failure
Cannot connect to the Dockerdaemon at
tcp://xxx:2375. ls thedocker daemon running?</p>
<p>此时需要修改docker的配置，开启docker的tcp://ip:2375服务</p>
<p><img src="https://www.lican.asia/images/portainer/1741742945997.png" alt="1741742945997"></p>
<ul>
<li>
<p>修改docker.service</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#a6e22e">vim</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">usr</span><span style="color:#f92672">/</span><span style="color:#a6e22e">lib</span><span style="color:#f92672">/</span><span style="color:#a6e22e">systemd</span><span style="color:#f92672">/</span><span style="color:#a6e22e">system</span><span style="color:#f92672">/</span><span style="color:#a6e22e">docker</span>.<span style="color:#a6e22e">service</span>
</span></span></code></pre></div></li>
<li>
<p>添加以下配置</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#f92672">-</span> <span style="color:#a6e22e">H</span> <span style="color:#a6e22e">tcp</span>:<span style="color:#75715e">//0.0.0.0:2375 -H unix:///var/run/docker.sock
</span></span></span></code></pre></div><p><img src="https://www.lican.asia/images/portainer/1741743171824.png" alt="1741743171824"></p>
</li>
<li>
<p>赋予docker.service权限</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#a6e22e">chmod</span> <span style="color:#f92672">+</span><span style="color:#a6e22e">x</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">usr</span><span style="color:#f92672">/</span><span style="color:#a6e22e">lib</span><span style="color:#f92672">/</span><span style="color:#a6e22e">systemd</span><span style="color:#f92672">/</span><span style="color:#a6e22e">system</span><span style="color:#f92672">/</span><span style="color:#a6e22e">docker</span>.<span style="color:#a6e22e">service</span>
</span></span></code></pre></div></li>
<li>
<p>重启docker</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#a6e22e">systemctl</span> <span style="color:#a6e22e">daemon</span><span style="color:#f92672">-</span><span style="color:#a6e22e">reload</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">systemctl</span> <span style="color:#a6e22e">restart</span> <span style="color:#a6e22e">docker</span>
</span></span></code></pre></div></li>
</ul>
<p>然后点击添加</p>
<p><img src="https://www.lican.asia/images/portainer/1741845871185.png" alt="1741845871185"></p>


                                        
                                    </div>

                                    

                                    

                                    
                                    
                                    

                                </div>
                            </article>
                        </div>
                    </div>
                </section>
                <aside class="sidebar sidebar-primary" id="sidebar-primary" role="complementary">
    <h1 class="screen-reader-text">Sidebar</h1>
    

    
    
    <section id="text-2" class="widget widget_text">
        <div class="textwidget">
            
            <div id="profile">
                <div id="profile_picture"><img src="https://www.lican.asia/logo/logo.png"></div>
                <div id="profile_intro">
                    <p><span class="name">Lican</span></p>
                    <p class="intro">全栈开发者，爱好造轮子。</p>
                </div>
            </div>
            
            <p>
                <script type="text/javascript">
                    (function ($) {
                        $(document).ready(function () {
                            var menuPrimaryContainer = $('#menu-primary-container');
                            var profile = $('#text-2');
                            $('#toggle-navigation').click(function () {
                                if (menuPrimaryContainer.hasClass('open')) {
                                    profile.removeClass('open');
                                } else {
                                    profile.addClass('open');
                                }
                            });
                        });
                    })(jQuery);
                </script>
            </p>
        </div>
    </section>
    
    
    
    
    
    <section id="text-5" class="widget widget_text">
        <h2 class="widget-title">开源项目</h2>
        <div class="textwidget">
            <div id="projects" style="line-height: 22px;">
                
                <a href="https://github.com/idoubi/gonews"
                    target="_blank">gonews</a>: &nbsp;Daily news for golang<br>
                
                <a href="https://github.com/idoubi/sql2struct"
                    target="_blank">sql2struct</a>: &nbsp;Generate go struct according to SQL<br>
                
                <a href="https://github.com/idoubi/goz"
                    target="_blank">goz</a>: &nbsp;Request library used in golang<br>
                
        </div>
    </section>
    
    

    
    
    
    
    <section id="qrcode" class="widget widget_media_image">
        <h2 class="widget-title">微信公众号</h2>
        <img width="258" height="258"
            src="https://www.lican.asia/wechat/lican.png"
            class="image wp-image-5514  attachment-full size-full" alt=""
            style="max-width: 100%; height: auto;"
            sizes="(max-width: 258px) 100vw, 258px">
    </section>
    
    

    
    
    

    
    
    

    
    
    
    
</aside>
            </div>
        </div>

        <footer id="site-footer" class="site-footer" role="contentinfo">
    <div class="max-width">
    </div>
    <div class="footer">
        <div id="footercontent">
            © lican.asia All rights reserved<br/>
            Built with Hugo Theme <a href="https://github.com/idoubi/hugo-theme-period" target="_blank">Period</a>
        </div>
    </div>
</footer>

<script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?e8351b6d4626d5881d439ea1f6184baa";
      var s = document.getElementsByTagName("script")[0]; 
      s.parentNode.insertBefore(hm, s);
    })();
</script>
    
    
    </div>
    
</body>

</html>